﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace LastfmNet.Models
{
    public class User : LastfmModelBase, IHasThreeImages
    {
        public User()
        {
            this.Name = string.Empty;
            this.RealName = string.Empty;
            this.ImageSmall = string.Empty;
            this.ImageMedium = string.Empty;
            this.ImageLarge = string.Empty;
            this.Url = string.Empty;
        }

        public User(XmlNode userNode)
        : this()
        {
            if (userNode == null) return;
            this.InitializeFromXmlNode(userNode);
        }

        public override void InitializeFromXmlNode(XmlNode node)
        {
            if (node == null) return;
            this.Name = node.GetChildValue("name");
            this.RealName = node.GetChildValue("realname");
            this.ImageSmall = node.GetChildValueWithSpecialAtrribute("image", "size", "small");
            this.ImageMedium = node.GetChildValueWithSpecialAtrribute("image", "size", "medium");
            this.ImageLarge = node.GetChildValueWithSpecialAtrribute("image", "size", "large");
            this.Url = node.GetChildValue("url");
        }

        public string Name { get; set; }

        public string RealName { get; set; }

        public string ImageSmall { get; set; }

        public string ImageMedium { get; set; }

        public string ImageLarge { get; set; }

        public string Url { get; set; }
    }
}
